<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="com.pay.sdk.*"%>
<%@ page import="com.pay.sdk.service.channel3.*"%>

<%
	// [重要]该页面仅为示例页面，在正式使用时，应当先对传入参数进行安全性检查和过滤，防止XSS等攻击。SDK中的方法没有对传入的参数进行任何检查和过滤。
	
	String type = request.getParameter("redirect_type");
	
	if("net_pay".equals(type)) {//已网通
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
		String total_fee = new String(request.getParameter("total_fee").getBytes("ISO-8859-1"), "UTF-8");
		String body = new String(request.getParameter("body").getBytes("ISO-8859-1"), "UTF-8");
		String card_type = new String(request.getParameter("card_type").getBytes("ISO-8859-1"), "UTF-8");
		String mobile = new String(request.getParameter("mobile").getBytes("ISO-8859-1"), "UTF-8");
		String client_ip = new String(request.getParameter("client_ip").getBytes("ISO-8859-1"), "UTF-8");
		String notify_url = new String(request.getParameter("notify_url").getBytes("ISO-8859-1"), "UTF-8");
		String time_expire = new String(request.getParameter("time_expire").getBytes("ISO-8859-1"), "UTF-8");
		String return_url = new String(request.getParameter("return_url").getBytes("ISO-8859-1"), "UTF-8");
		String lon = new String(request.getParameter("lon").getBytes("ISO-8859-1"), "UTF-8");
		String lat = new String(request.getParameter("lat").getBytes("ISO-8859-1"), "UTF-8");
		String attach = new String(request.getParameter("attach").getBytes("ISO-8859-1"), "UTF-8");
		// 【重要】出于安全考虑，在调用函数前，需要对上面的参数进行防护过滤等操作
		ChannelThreePay.prePay(out_trade_no, total_fee, body, card_type, client_ip, mobile, notify_url, time_expire, return_url, attach, lon, lat);
	}else if("net_pay_query".equals(type)){//一网通查询
		String out_trade_no = new String(request.getParameter("out_trade_no").getBytes("ISO-8859-1"), "UTF-8");
		String transation_id = new String(request.getParameter("transation_id").getBytes("ISO-8859-1"), "UTF-8");
		String out_transation_id = new String(request.getParameter("out_transation_id").getBytes("ISO-8859-1"), "UTF-8");
		out.println(ChannelThreePay.prePayQuery(out_trade_no, transation_id, out_transation_id));
	}
%>